﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_ACEIndex.cshtml";
}


@this.Partial("Index-js")
<script>
    var resourceList=@this.Raw(this.ViewBag.MenusListString)
</script>
<div class="topPanel">
    <div class="toolbar">
        <div class="btn-group">
            <a class="btn btn-primary" onclick="$ace.reload()"><span class="glyphicon glyphicon-refresh"></span></a>
        </div>
        <div class="btn-group">
            <button class="btn btn-primary" data-bind="click:Edit ,attr:{disabled:!DataTable.SelectedModel()}" ><i class="fa fa-pencil-square-o"></i>修改</button>
            <button class="btn btn-primary" data-bind="click:Delete ,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-trash-o"></i>删除</button>
            <button class="btn btn-primary" data-bind="click:Add"><i class="fa fa-plus"></i>添加</button>
            <button class="btn btn-primary" data-bind="click:Detail ,attr:{disabled:!DataTable.SelectedModel()}"><i class="fa fa-pencil-square-o"></i>详情</button>
        </div>

    </div>
    <div class="search">
        <table>
            <tr>
                <td>
                    <div class="input-group">
                        <input id="txt_keyword" type="text" class="form-control" placeholder="名称" style="width: 200px;" data-bind="value:SearchModel().keyword">
                        <span class="input-group-btn">
                            <button id="btn_search" type="button" class="btn  btn-primary" data-bind="click:Search"><i class="fa fa-search"></i></button>
                        </span>
                    </div>
                </td>
            </tr>
        </table>
    </div>
</div>

<div class="table-responsive">
    <table class="table table-hover" data-bind="with:DataTable">
        <thead>
            <tr>
                <th style="width: 20px;"></th>
                <th>名称</th>
                <th>类型</th>
                <th>路径</th>
                <th>排序</th>
                <th>上级</th>
                <th>级别</th>
                @*<th>左图标</th>
                <th>右图标</th>
                <th>样式</th>
                <th>提示数</th>*@
                <th>脚本</th>
                <th>备注</th>
            </tr>
        </thead>
        <tbody data-bind="foreach:Models">
            <tr data-bind="click:$parent.SelectRow, attr: { id: $data.Data.id, 'parent-id': $data.Data.resourceowner }">
                <td data-bind="text:$parent.GetOrdinal($index())"></td>
                <td>
                    <!-- ko if: $data.HasChildren -->
                    <div onclick="expandChildren(this);" style="left: 0px; cursor: pointer;" class="glyphicon glyphicon-triangle-bottom" data-bind=""></div>
                    <!-- /ko -->
                    <!-- ko if: !$data.HasChildren() -->
                    <div style="width: 12px; height: 12px; display: inline-block;"></div>
                    <!-- /ko -->
                    <span data-bind="html:appendRetract($data.Level())"></span>
                    <span data-bind="text:$data.Data.resourcename"></span>
                </td>
                <td data-bind="text:$root.FormatOpenTarget($data.Data.resourcetype())"></td>
                <td data-bind="text:$data.Data.resourceurl"></td>
                <td data-bind="text:$data.Data.order"></td>
                <td data-bind="text: $ace.getOptionTextByValue(resourceList,$data.Data.resourceowner())"></td>
                <td data-bind="text:$data.Data.resourcelevel"></td>
                @*<td data-bind="text:$data.Data.resourceleftico"></td>
                <td data-bind="text:$data.Data.resourcerightico"></td>
                <td data-bind="text:$data.Data.resourceclass"></td>
                <td data-bind="text:$data.Data.resourcenumber"></td>*@
              <td data-bind="text:$ace.getFuzzyContent($data.Data.resourcescript()),attr:{herf:'#',title:$data.Data.resourcescript}"></td>
                <td data-bind="text:$ace.getFuzzyContent($data.Data.description()),attr:{herf:'#',title:$data.Data.description}"></td>
            </tr>
        </tbody>
@*        @this.Partial("_tfoot")*@
    </table>
</div>

@using (Html.Dialog())
{
    <form id="form1">
        <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
            <div style="padding-top: 20px; margin-right: 30px;">
                <table class="form">
                    <tr>
                        <td class="formTitle">名称<span style="color:red">*</span></td>
                        <td class="formValue">
                            <input id="resourcename" name="resourcename" type="text" class="form-control required" placeholder="请输入名称" data-bind="value:Model().resourcename" />
                        </td>
                        <td class="formTitle">类型<span style="color:red">*</span></td>
                        <td class="formValue">
                            <select id="resourcetype" name="resourcetype" class="form-control required" data-bind="value:Model().resourcetype">
                                <option value="">==请选择==</option>
                                <option value="1" title="1">菜单</option>
                                <option value="2" title="2">工具条</option>
                                <option value="3" title="3">按钮</option>
                                <option value="4" title="4">脚本</option>
                                <option value="5" title="5">文件</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">路径</td>
                        <td class="formValue">
                            <input id="resourceurl" name="resourceurl" type="text" class="form-control" data-bind="value:Model().resourceurl" />
                        </td>
                        <td class="formTitle">排序</td>
                        <td class="formValue">
                            <input id="order" name="order" type="text" class="form-control" data-bind="value:Model().order" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">上级</td>
                        <td class="formValue">
                            <select id="resourceowner" name="resourceowner" class="form-control required" data-bind="options:$root.Menus,optionsText:'text',optionsValue:'id', optionsCaption:'根节点',value:Model().resourceowner"></select>
                        </td>
                        <td class="formTitle">级别</td>
                        <td class="formValue">
                            <input id="resourcelevel" name="resourcelevel" type="text" class="form-control required" data-bind="value:Model().resourceleval" />
                        </td>
                    </tr>
                    @*<tr>
                        <td class="formTitle">左图标</td>
                        <td class="formValue">
                            <input id="resourceleftico" name="resourceleftico" type="text" class="form-control" data-bind="value:Model().resourceleftico" />
                        </td>
                        <td class="formTitle">右图标</td>
                        <td class="formValue">
                            <input id="resourcerightico" name="resourcerightico" type="text" class="form-control" data-bind="value:Model().resourcerightico" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">样式</td>
                        <td class="formValue">
                            <input id="resourceclass" name="resourceclass" type="text" class="form-control" data-bind="value:Model().resourceclass" />
                        </td>
                        <td class="formTitle">提示数</td>
                        <td class="formValue">
                            <input id="resourcenumber" name="resourcenumber" type="text" class="form-control" data-bind="value:Model().resourcenumber" />
                        </td>
                    </tr>*@

                    <tr>
                        <td class="formTitle" valign="top" style="padding-top: 5px;">脚本
                        </td>
                        <td class="formValue" colspan="3">
                            <textarea id="resourcescript" name="resourcescript" class="form-control" style="height: 60px;" data-bind="value:Model().resourcescript"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle" valign="top" style="padding-top: 5px;">备注
                        </td>
                        <td class="formValue" colspan="3">
                            <textarea id="description" name="description" class="form-control" style="height: 60px;" data-bind="value:Model().description"></textarea>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>


}
@using (Html.Dialog("DetailDialog", "DetailDialog", 800))
{
    <form id="DetailForm">
        <div style="margin-top: 10px; margin-left: 10px; margin-right: 10px;">
            <div style="padding-top: 20px; margin-right: 30px;">
                <table class="form">
                    <tr>
                        <td class="formTitle">名称：<span style="color:red">*</span></td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourcename"></label>
                        </td>
                        <td class="formTitle">类型：<span style="color:red">*</span></td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:$root.FormatOpenTarget(Model().resourcetype) "></label>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">路径：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourceurl"></label>
                        </td>
                        <td class="formTitle">排序：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().order"></label>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">上级：<span style="color:red">*</span></td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:$ace.getOptionTextByValue(resourceList,Model().resourceowner)"></label>
                        </td>
                        <td class="formTitle" valign="top" style="padding-top: 5px;">脚本：
                        </td>
                        <td class="formValue" >
                            <label class="form-control" data-bind="text:Model().resourcescript"></label>
                        </td>

                        @*<td class="formTitle">级别：<span style="color:red">*</span></td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourcelevel"></label>
                        </td>*@
                    </tr>
                    @*<tr>
                        <td class="formTitle">左图标：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourceleftico"></label>
                        </td>
                        <td class="formTitle">右图标：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourcerightico"></label>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">样式：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourceclass"></label>
                        </td>
                        <td class="formTitle">提示数：</td>
                        <td class="formValue">
                            <label class="form-control" data-bind="text:Model().resourcenumber"></label>
                        </td>
                    </tr>*@
                    <tr>
                        <td class="formTitle" valign="top" style="padding-top: 5px;">备注：
                        </td>
                        <td class="formValue" colspan="3">
                            <label class="form-control" data-bind="text:Model().description"></label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </form>


}
